home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 1044 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.7 KB

  1. Path: news.mindlink.net!news
  2. From: genew@mindlink.bc.ca (Gene Wirchenko)
  3. Newsgroups: alt.msdos.programmer,comp.lang.c
  4. Subject: Re: Some C problems
  5. Date: Thu, 11 Jan 1996 03:45:26 GMT
  6. Organization: MIND LINK! - British Columbia, Canada
  7. Message-ID: <4d21cq$t5g@fountain.mindlink.net>
  8. References: <4d0fjj$eok@lugb.latrobe.edu.au>
  9. NNTP-Posting-Host: line221.nwm.mindlink.net
  10. X-Newsreader: Forte Free Agent 1.0.82
  11.  
  12. cs102238@lux.latrobe.edu.au (Gregary John Boyles ) wrote:
  13.  
  14. >PROBLEM 1.
  15. [snip]
  16.  
  17. >With this statement DiskInfo.df_total*DiskInfo.df_sclus*DiskInfo.df_bsec calculated
  18. >using my calculator produces the correct drive capacity i.e. 360K however
  19. >DriveSize does not contain the correct value i.e. 32000 instead of 360000 (approximate).
  20. >Why is this happening? The above fields are of type unsigned.
  21.  
  22. >PROBLEM 2.
  23. >long DriveSize;
  24. >struct dfree DiskInfo;
  25. >.
  26. >.
  27. >.
  28.  
  29. >getdfree(DriveNum,&DiskInfo);
  30. >DriveSize=DiskInfo.df_total*DiskInfo.df_sclus*DiskInfo.df_bsec;
  31.  
  32.      What are the types of the vars in the multiplication?  If they
  33. were (say) all int, there would be no type conversion.  Overflow could
  34. occur.  This is probably your problem.
  35.  
  36. >df_total:clusters
  37. >df_sclus:sectors/cluster
  38. >df_bsec:bytes/sector
  39.  
  40.  
  41. >PROBLEM 3.
  42. >When I want to output a long int type varaible with printf, it prints out
  43. >a garbage value for the variable despite declaring it as a li/ld in the
  44. >format string. What am I doing wrong?
  45.  
  46.      1) What is the value of the variable?  If it contains a garbage
  47. value, that's what you'll get.  2) Maybe your printf() is wrong: post
  48. it.
  49.   
  50. >PROBLEM 4.
  51. [snip]
  52.  
  53. Sincerely,
  54.  
  55. Gene Wirchenko
  56.  
  57. C Pronunciation Guide:
  58.      y=x++;     "wye equals ex plus plus semicolon"
  59.      x=x++;     "ex equals ex doublecross semicolon"
  60.  
  61.